function foo(params) {
  console.log(params);
}

function bar() {
  console.log("我来执行 setTimeout is done");
}

function runInMs(title = "runIn300ms", ms = 300) {
  console.time(title);
  let i = 1;
  const length = ms * 1000000;
  while (i < length) {
    i++;
  }
  console.timeEnd(title);
}

function mockFetch() {
  return new Promise((resolve) => {
    runInMs("runIn1000ms in promise", 1000);
    resolve("我来执行 Promise resolved");
  });
}

// 开始执行

// 必须在浏览器中执行
setTimeout(bar, 0);

const futureData = mockFetch();
futureData.then(foo);

runInMs();

console.log("我先来执行");
